-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Initialize authentication adapters only once at server start #8464
base: alpha
Are you sure you want to change the base?
Conversation
I will reformat the title to use the proper commit message syntax. |
Thanks for opening this pull request! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #8464 +/- ##
==========================================
+ Coverage 94.15% 94.40% +0.24%
==========================================
Files 186 184 -2
Lines 14688 14625 -63
==========================================
- Hits 13829 13806 -23
+ Misses 859 819 -40 ☔ View full report in Codecov by Sentry. |
If this a performance improvement or just an code style refactor without significant implications? |
It should be a minor performance increase, but mostly intended as a functionality change as at the moment errors in auth config are only called once the auth is used. Most of the old auth adapters are js objects so reconstruction probably has minimal impact. As we move towards making them |
Okay; then let's use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr seems complicate to me to just achieve a cache on getValidatorForProvider.
Here you can Object.keys over authOptions of module.exports = function (authOptions = {}, enableAnonymousUsers = true) {
and using a factory pre compute each getValidatorForProvider
i also discovered here a source of truth issue about the runAftetFind request object, it will be super hard to maintain the request object if the interface is not linked to a single source of truth. You should refactor this part to use the standard getRequestObject
Signed-off-by: Daniel <[email protected]>
Cache is required here otherwise each adapter is constructed each time an auth method is called. An auth adapter should be constructed once and then used across the rest of the server instance |
Signed-off-by: Manuel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @Moumouls want to give this a quick review before we merge?
The definitions check fails, not sure if that is because I've merged alpha into this branch, or it may be flaky.
It seems that the tests are passing; is this ready for merge? |
Pull Request
Issue
Currently, AuthAdapters can be constructed each time a auth call is called. This means
validateOptions
is called too much.Closes: #8463
Approach
Loads adapters on server init
Tasks